HAL1 CRYP –> HAL2 AES

This section provides information about the HAL AES constants migration .

Error code

HAL1

HAL2

#define HAL_CRYP_ERROR_NONE
#define HAL_AES_ERROR_NONE
#define HAL_CRYP_WRITE_ERROR
/* or  */
#define HAL_CRYP_ERROR_WRITE
#define HAL_AES_ERROR_WRITE
#define HAL_CRYP_READ_ERROR
/* or  */
#define HAL_CRYP_ERROR_READ
#define HAL_AES_ERROR_READ
#define HAL_CRYP_ERROR_KEY
#define HAL_AES_ERROR_KEY
#define HAL_CRYP_ERROR_RNG
#define HAL_AES_ERROR_RNG
#define HAL_CRYP_DMA_ERROR
/* or  */
#define HAL_CRYP_ERROR_DMA
#define HAL_AES_ERROR_DMA
#define HAL_CRYP_BUSY_ERROR
#define HAL_CRYP_ERROR_BUSY
#define HAL_CRYP_ERROR_TIMEOUT
#define HAL_CRYP_ERROR_NOT_SUPPORTED
#define HAL_CRYP_ERROR_AUTH_TAG_SEQUENCE
#define HAL_CRYP_ERROR_INVALID_CALLBACK
  • Removed; These kinds of logical errors are reported by the direct function return.


Algorithm / chaining mode

HAL1

HAL2

#define  CRYP_CHAINMODE_AES_ECB
#define  CRYP_AES_ECB
#define  CRYP_CHAINMODE_AES_CBC
#define  CRYP_AES_CBC
#define  CRYP_CHAINMODE_AES_CTR
#define  CRYP_AES_CTR
#define  CRYP_CHAINMODE_AES_GCM_GMAC
#define  CRYP_AES_GCM_GMAC
#define  CRYP_AES_GCM
#define  CRYP_CHAINMODE_AES_CCM
#define  CRYP_AES_CCM
#define  CRYP_CHAINMODE_AES_CMAC
  • Removed; In HAL2 the global configuration function has been split into dedicated configuration functions per algorithm,eliminating the need to explicitly specify the algorithm.


DMA input phase management constants

HAL1

HAL2

#define  CRYP_DMAIN_ENABLE
#define  CRYP_DMAOUT_ENABLE
#define  CRYP_DMAOUT_DISABLE
#define  CRYP_DMAIN_DISABLE
  • Removed; In HAL2, all DMA input phase management is handled internally.


GCM/GMAC and CCM/CMAC processing phase constants

HAL1

HAL2

#define CRYP_GCM_INIT_PHASE
#define CRYP_GCMCMAC_HEADER_PHASE
#define CRYP_GCM_PAYLOAD_PHASE
#define CRYP_GCMCMAC_FINAL_PHASE
#define CRYP_INIT_PHASE
#define CRYP_HEADER_PHASE
#define CRYP_PAYLOAD_PHASE
#define CRYP_FINAL_PHASE
  • Removed; In HAL2, processing phases have been removed from the global configuration function and are now used internally.


Enable state constants

HAL1

HAL2

#define CRYP_AES_DISABLE
#define CRYP_AES_ENABLE
  • Removed; In HAL2, state constants are used internally.


Operating mode constants

HAL1

HAL2

#define CRYP_ALGOMODE_ENCRYPT
#define CRYP_ALGOMODE_KEYDERIVATION
#define CRYP_ALGOMODE_DECRYPT
#define CRYP_ALGOMODE_KEYDERIVATION_DECRYPT
#define CRYP_ALGOMODE_TAG_GENERATION
  • Removed; In HAL2, all operating mode constants have been removed from the global configuration function and are now specified directly within the encryption and decryption functions.


Key and init vector configuration skip mode constants

HAL1

HAL2

#define CRYP_KEYIVCONFIG_ALWAYS
#define CRYP_KEYIVCONFIG_ONCE
#define CRYP_KEYNOCONFIG
#define CRYP_IVCONFIG_ONCE
  • Removed; In in HAL2 the AES key is no longer part of the global configuration function. Instead, it is provided through the HAL_AES_SetNormalKey(), HAL_AES_SetSharedKey(), or HAL_AES_SetHWKey() APIs.Likewise, the initialization vector has been removed from the global configuration and is now supplied via the dedicated configuration functions


Data width unit constants

HAL1

HAL2

#define CRYP_DATAWIDTHUNIT_WORD
#define CRYP_DATAWIDTHUNIT_BYTE
  • Removed; In HAL2 all processing functions operate on byte-sized data,making the global data-width configuration parameter obsolete.


Header width unit constants

HAL1

HAL2

#define CRYP_HEADERWIDTHUNIT_WORD
#define CRYP_HEADERWIDTHUNIT_BYTE
  • Removed; in HAL2 the header size in configuration functions is expressed in bytes,making the global header‑width configuration parameter obsolete.


Clear flags constants

HAL1

HAL2

#define CRYP_CLEAR_CCF
#define CRYP_CCF_CLEAR
#define CRYP_ERR_CLEAR
#define CRYP_CLEAR_RWEIF
#define CRYP_CLEAR_RNGEIF
  • Removed; Clear-flag constants have been removed and replaced with dedicated static inline functions for clearing each flag,which are now documented in HAL AES Macros section.


Key size constants

HAL1

HAL2

#define CRYP_KEYSIZE_128B
#define CRYP_KEYSIZE_256B
#define HAL_AES_KEY_SIZE_128BIT
#define HAL_AES_KEY_SIZE_256BIT

Flags constants

HAL1

HAL2

#define CRYP_FLAG_BUSY
#define CRYP_FLAG_WRERR
#define CRYP_FLAG_RDERR
#define CRYP_FLAG_CCF
#define CRYP_FLAG_KEYVALID
#define CRYP_FLAG_KEIF
#define CRYP_FLAG_RWEIF
#define CRYP_FLAG_RNGEIF
#define HAL_AES_FLAG_BUSY
#define HAL_AES_FLAG_WRERR
#define HAL_AES_FLAG_RDERR
#define HAL_AES_FLAG_CC
#define HAL_AES_FLAG_KEYVALID
#define HAL_AES_FLAG_KERR
#define HAL_AES_FLAG_RDWRERR
#define HAL_AES_FLAG_RNGERR

Interrupts enable bits constants

HAL1

HAL2

#define CRYP_IT_CCFIE
#define CRYP_IT_ERRIE
#define CRYP_IT_RWEIE
#define CRYP_IT_KEIE
#define CRYP_IT_RNGEIE
#define HAL_AES_IT_CC
Not yet implemented in HAL2
#define HAL_AES_IT_RDWRERR
#define HAL_AES_IT_KERR
#define HAL_AES_IT_RNGERR

Interrupts flags constants

HAL1

HAL2

#define CRYP_IT_WRERR
#define CRYP_IT_RDERR
#define CRYP_IT_CCF
#define HAL_AES_ERROR_WRITE
#define HAL_AES_ERROR_READ
#define HAL_AES_FLAG_CC

Key select constants

HAL1

HAL2

#define CRYP_KEYSEL_NORMAL
#define CRYP_KEYSEL_HW
#define CRYP_KEYSEL_SW
#define CRYP_KEYSEL_HSW
Removed; used in the private code
#define HAL_AES_KEY_SELECT_DHUK
#define HAL_AES_KEY_SELECT_BHK
#define HAL_AES_KEY_SELECT_DHUK_XOR_BHK

Key protection constants

HAL1

HAL2

#define CRYP_KEYPROT_ENABLE
#define CRYP_KEYPROT_DISABLE
#define HAL_AES_KEY_PROTECTION_ENABLED
#define HAL_AES_KEY_PROTECTION_DISABLED

Data type constants

HAL1

HAL2

#define CRYP_DATATYPE_32B
/* or  */
#define CRYP_NO_SWAP
#define HAL_AES_DATA_SWAPPING_NO
#define CRYP_DATATYPE_16B
/* or  */
#define CRYP_HALFWORD_SWAP
#define HAL_AES_DATA_SWAPPING_HALFWORD
#define CRYP_DATATYPE_8B
/* or  */
#define CRYP_BYTE_SWAP
#define HAL_AES_DATA_SWAPPING_BYTE
#define CRYP_DATATYPE_1B
/* or  */
#define CRYP_BIT_SWAP
#define HAL_AES_DATA_SWAPPING_BIT

Key mode constants

HAL1

HAL2

#define CRYP_KEYMODE_NORMAL
#define CRYP_KEYMODE_SHARED
#define CRYP_KEYMODE_WRAPPED
#define HAL_AES_KEY_MODE_NORMAL
#define HAL_AES_KEY_MODE_SHARED
#define HAL_AES_KEY_MODE_WRAPPED

Related concept: